package com.github.blanexie.nexusj.torrent.infra.repository

import com.github.blanexie.nexusj.torrent.domain.valobj.*
import org.ktorm.jackson.json
import org.ktorm.schema.*


object TorrentDO : Table<Nothing>("torrent") {

    var id = int("id")
    var infoHash = varchar("info_hash")
    var title = varchar("title")
    var category = varchar("category")
    var coverPath = varchar("cover_path")

    var status = int("status")
    var createTime = datetime("create_time")
    var updateTime = datetime("update_time")

    //torrent
    val announce = varchar("announce")
    val announceList = json<List<String>>("announce_list")
    val comment = varchar("comment")
    val commentUtf8 = varchar("comment_utf8")
    val creationDate = long("creation_date")
    val encoding = varchar("encoding")
    val nodes = json<List<String>>("nodes")

    //info
    var length = long("length")
    val files = json<List<Files>>("files")
    val name = varchar("name")
    val nameUtf8 = varchar("name_utf8")
    val pieceLength = long("piece_length")
    val pieces = blob("pieces")
    val publisher = varchar("publisher")
    val publisherUtf8 = varchar("publisher_utf8")
    val publisherUrl = varchar("publisher_url")
    val publisherUrlUtf8 = varchar("publisher_url_utf8")

    //description
    var description = text("description")
    var descImgs = json<List<String>>("desc_imgs")

    //ration
    var ration = float("ration")
    var rationStartTime = datetime("ration_start_time")
    var rationEndTime = datetime("ration_end_time")

    // 状态数据统计
    var completeCount = int("complete_count")
    var downloadCount = int("download_count")
    var seedCount = int("seed_count")
}
